package com.heima.user.controller;

import com.heima.model.admin.dtos.AuthDto;
import com.heima.model.admin.pojos.ApUserRealname;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.user.pojos.ApUser;
import com.heima.user.mapper.ApUserMapper;
import com.heima.user.service.IAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping
public class AuthController {

    @Autowired
    private IAuthService authService;

    @Autowired
    private ApUserMapper apUserMapper;

    /**
     * 用户审核列表查询，feign远程调用
     * @param authDto
     * @return
     */
    @PostMapping("/api/v1/auth/list")
    ResponseResult list(@RequestBody AuthDto authDto){
        return authService.list(authDto);
    }
    /**
     * 用户审核失败，feign远程调用
     * @param authDto
     * @return
     */
    @PostMapping("/api/v1/auth/authFail")
    ResponseResult fail(@RequestBody AuthDto authDto){
        return authService.fail(authDto);
    }
    /**
     * 用户审核通过，feign远程调用
     * @param authDto
     * @return
     */
    @PostMapping("/api/v1/auth/authPass")
    ResponseResult pass(@RequestBody AuthDto authDto){
        return authService.pass(authDto);
    }


    @GetMapping("/api/v1/getNameById/{id}")
    String getById(@PathVariable Long id){
        ApUser user = apUserMapper.selectById(id);
        return user.getName();
    }

}
